// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import router from './router'
import axios from './http'
import store from './store'
import 'babel-polyfill'
import SlideVerify from 'vue-monoplasty-slide-verify'
import VueI18n from 'vue-i18n'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import tcLocale from 'element-ui/lib/locale/lang/zh-TW'
import ElementLocale from 'element-ui/lib/locale'

import 'jquery'
Vue.use(VueI18n) // 通过插件的形式挂载
const messages = {
  en: Object.assign(require('./language/en'), enLocale),
  'zh-CN':Object.assign(require('./language/zh'), zhLocale),
  'zh-TW':Object.assign(require('./language/tw'), tcLocale)
}

var type = navigator.appName,lang;
if (type == "Netscape") {
    lang = navigator.language; //获取浏览器配置语言，支持非IE浏览器
} else {
    lang = navigator.userLanguage; //获取浏览器配置语言，支持IE5+ == navigator.systemLanguage
}
if (lang != "zh-CN" && lang != "en" && lang != "zh-TW") {
    lang = "zh-CN"; //获取浏览器配置语言前两位
} else {
    lang = lang; //获取浏览器配置语言前两位
}
if(sessionStorage.getItem("lang") == 'undefined' || sessionStorage.getItem("lang") == null){
    sessionStorage.setItem("lang", lang);
}
const i18n = new VueI18n({
  locale:sessionStorage.getItem("lang")==undefined || sessionStorage.getItem("lang")==null?'zh-CN':sessionStorage.getItem("lang"),    // 语言标识
  messages
})
ElementLocale.i18n((key, value) => i18n.t(key, value))

Vue.use(ElementUI);
Vue.use(SlideVerify);
Vue.config.productionTip = false
Vue.prototype.$axios=axios
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  components: { App },
  template: '<App/>'
})
